<template>
  <el-select v-model="value" multiple filterable remote reserve-keyword placeholder="搜索直播" :remote-method="remoteMethod"
    :loading="loading">
    <el-option v-for="item in options" :key="item.id" :label="item.title" :value="item.id" />
  </el-select>
</template>

<script setup lang='ts'>
import { page } from '@/modules/live/api/live';
const task_model = inject('task_model') as any
const model = defineModel({
  default:[]
})

const options = ref<any[]>(task_model?.lives||[])
const value = computed({
  get:()=>model.value,
  set:v=>model.value = v
})
const loading = ref(false)

const remoteMethod = (query: string) => {
  if (query) {
    loading.value = true
    page({
      title: query,
      page_size: 1000
    }).then(res => {
      options.value = res.data.list
      loading.value = false;
    })
  } else {
    options.value = []
  }
}

</script>

<style></style>
